# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=whoosh
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=2.7.4
pkgrel=3
pkgdesc="Fast, pure-Python full text indexing, search, and spell checking library (mingw-w64)"
url='https://bitbucket.org/mchaput/whoosh/wiki/Home'
license=('BSD')
arch=('any')
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             'mercurial')
checkdepends=("${MINGW_PACKAGE_PREFIX}-python2-pytest-runner"
              "${MINGW_PACKAGE_PREFIX}-python3-pytest-runner")
_dtoken="53/72/6c6f1e787d9cab2cc733cf042f125abec07209a58308831c9f292504e826"
source=("hg+https://bitbucket.org/mchaput/${_realname}#tag=${pkgver}")
sha256sums=('SKIP')

prepare() {
  cd ${srcdir}
  cp -r ${_realname} build-python2
  cp -r ${_realname} build-python3
}

package_python3-whoosh() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3")
  cd ${srcdir}/build-python3
  ${MINGW_PREFIX}/bin/python3 setup.py build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}"

  install -D -m644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}"/share/licenses/python3-${_realname}/LICENSE.txt
}

package_python2-whoosh() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2")
  cd ${srcdir}/build-python2
  ${MINGW_PREFIX}/bin/python2 setup.py build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}"

  install -D -m644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}"/share/licenses/python2-${_realname}/LICENSE.txt
}

package_mingw-w64-i686-python2-whoosh() {
  package_python2-whoosh
}

package_mingw-w64-i686-python3-whoosh() {
  package_python3-whoosh
}

package_mingw-w64-x86_64-python2-whoosh() {
  package_python2-whoosh
}

package_mingw-w64-x86_64-python3-whoosh() {
  package_python3-whoosh
}
